const path = require("path");
const { name } = require("./package");

function resolve(dir) {
    return path.join(__dirname, dir);
}

const port = 3000; // dev port

module.exports = {
    outputDir: "dist",
    assetsDir: "static",
    filenameHashing: true,
    devServer: {
        host: "0.0.0.0",
        hot: true,
        disableHostCheck: true,
        port,
        overlay: {
            warnings: false,
            errors: true
        },
        // 跨域
        headers: {
            "Access-Control-Allow-Origin": "*"
        }
    },
    // 自定义webpack配置
    configureWebpack: {
        resolve: {
            alias: {
                "@": resolve("src")
            }
        },
        output: {
            // 把子应用打包成 umd 库格式(必须)
            library: `${name}-[name]`,
            libraryTarget: "umd",
            jsonpFunction: `webpackJsonp_${name}`
        }
    }
};
